# blls/abstract_base_bll.py
import logging
from enumobjects.general_enum import YesOrNoEnum
from utils.common_util import CommonUtil


class AbstractBaseBLL(object):
    def __init__(self, request, cls=None, unique_fields=None):
        self.request = request
        self.cls = cls
        self.unique_fields = unique_fields
        self.db_session = self._get_db_session()
        self.standardized_session = self._get_standardized_session()
        # self.tokenizer = self._get_tokenizer()
        # self.model = self._get_model()
        # self.chroma_client = self._get_chroma_client()

    @property
    def _get_db_session(self):
        # 优先使用类属性，若未设置则尝试从 request 获取
        return self.request.db_session if hasattr(self.request, "db_session") else None

    @property
    def _get_standardized_session(self):
        return self.request.standardized_session if hasattr(self.request, "standardized_session") else None